IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_GetTCHCLevel]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_GetTCHCLevel]
GO

/****** Object:  StoredProcedure [dbo].[sp_GetTCHCLevel]    Script Date: 08/25/2011 23:17:48 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[sp_GetTCHCLevel]
	@ToChucHanhChinhID int,
	@ToChucHanhChinhLevel int output
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	SET NOCOUNT ON;
 IF @ToChucHanhChinhID IS NULL 
 BEGIN
  RAISERROR ('Ban phai nhap NSToChucHanhChinhID',16,1)
  RETURN
 END
 
Set @ToChucHanhChinhLevel = ( SELECT tchc.ToChucHanhChinhLevel
								FROM CHToChucHanhChinh tchc
								WHERE tchc.ToChucHanhChinhID = @ToChucHanhChinhID)
END

GO

--exec [sp_GetNsToChucByTCHC] @ToChucHanhChinhID=3